from pagemagic.utils.openid.views import SESSION_OPENID_USER_VARNAME
from pagemagic.utils.openid.models import OpenidUser

class MixOpenidUserMiddleware:
    def process_request(self, request):
        user_id = request.session.get(SESSION_OPENID_USER_VARNAME)
        if user_id:
            request.openid_user = OpenidUser.objects.get(id=user_id)
        else:
            request.openid_user = None

